package com.gscitysfy.cus.drain.modules.duty.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.gscitysfy.cloudfrmwk.assistant.domain.Result;

import com.gscitysfy.cus.drain.annotations.DictTranslation;
import com.gscitysfy.cus.drain.annotations.FieldParam;
import com.gscitysfy.cus.drain.constants.DicConstant;
import com.gscitysfy.cus.drain.modules.duty.service.IMoperDutyScheduleService;
import com.gscitysfy.cus.drain.modules.duty.vo.MoperDutyMnRotaVo;
import io.swagger.v3.oas.annotations.Operation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletResponse;

/**
 * @description: 值班排班接口
 * @author 刘少华
 * @version 1.0
 * @date 2022/3/28 9:03
 */

@RestController
@RequestMapping("/duty")
public class MoperDutyScheduleController {

    @Autowired
    private IMoperDutyScheduleService dutyScheduleService;

    /**
     * 分条件按日期分组查询排班
     * @param startTime
     * @param endTime
     * @param personType
     * @param coamClass
     * @param isOwn
     * @return Result
     */
    @GetMapping ("/listDutySchedule")
    @DictTranslation({@FieldParam(dictType = DicConstant.DUTY_TYPE, targetField = "coamPersonType")})
    @Operation(summary = "值班日历查询", description = "根据查询条件查询值班日历信息")
    public Result listDutySchedule(String startTime, String endTime, String personType, String coamClass, String isOwn,String personId){
        return Result.content(dutyScheduleService.listDutyScheduleGroupByDate(startTime,endTime,personType,coamClass,isOwn,personId));
    }

    /**
     *
     * @param dutyTime
     * @param personType
     * @param coamClass
     * @param personId
     * @return
     */
    @PostMapping("/getDutySchedule")
    @DictTranslation({@FieldParam(dictType = DicConstant.DUTY_TYPE, targetField = "coamPersonType")})
    @Operation(summary = "值班日历查询", description = "根据查询条件查询值班日历信息")
    public Result getDutySchedule(String dutyTime, String personType, String coamClass,String personId,String isAll){
        return Result.content(dutyScheduleService.getDutySchedule(dutyTime,personType,coamClass,personId,isAll));
    }


    /**
     * 分页查询值班人员接口
     * @param page
     * @param startTime
     * @param endTime
     * @param personName
     * @param coamClass
     * @return
     */
    @GetMapping("/listDutySchedulePage")
    @DictTranslation({@FieldParam(dictType = DicConstant.DUTY_TYPE, targetField = "coamPersonType")})
    @Operation(summary = "值班分页列表查询", description = "根据查询条件查询值班分页列表")
    public Result listDutySchedulePage(Page<MoperDutyMnRotaVo> page, String startTime, String endTime, String personName, String coamClass){
        return Result.content(dutyScheduleService.listDutySchedulePage(page,startTime,endTime,personName,coamClass));
    }

    /**
     * 按条件导出值班日历
     * @param response
     * @param startTime
     * @param endTime
     * @param personType
     * @param coamClass
     * @param isOwn
     */
    @GetMapping("/exportDutySchedule")
    @Operation(summary = "导出值班日历", description = "根据查询条件导出值班日历信息")
    public void exportDutySchedule(HttpServletResponse response, String startTime, String endTime, String personType, String coamClass, String isOwn){
        dutyScheduleService.exportDutySchedule(response,startTime,endTime,personType,coamClass,isOwn);
    }

}
